#!/usr/bin/env python3
# coding:utf-8
import requests
import json
# server_url = 'http://0.0.0.0:8080/core/task/'
server_url = 'http://127.0.0.1:8000/blog'


def add():
    data = {'username': 'admin1', 'password': '123456', 'email': '12@163.com'}
    url = server_url + '/register/'
    headers = {'Content-Type': 'application/json'}
    r = requests.post(url, json=data, headers=headers)
    # r = requests.post(url, headers=headers)
    # r = requests.get(url)
    print(type(r))
    print(r)

def login():
    data = {'username': 'hairy', 'password': 'lhr308301'}
    url = server_url + '/login/'
    headers = {'Content-Type': 'application/json'}
    r = requests.post(url, json=data, headers=headers)
    # r = requests.post(url, headers=headers)
    # r = requests.get(url)
    print(type(r))
    # print(r)

def register():
    data = {'email': '12132@163.com', 'password': 'lhr308301', 'password2': 'lhr308301'}
    url = server_url + '/register/'
    headers = {'Content-Type': 'application/json'}
    r = requests.post(url, json=data, headers=headers)
    # r = requests.post(url, headers=headers)
    # r = requests.get(url)
    print(type(r))
    # print(r)


add()
# login()
# register()